import JSEncrypt from "jsencrypt"
// import NodeRSA from 'node-rsa'
import store from '../store'
export default function (argument) {
  let string = JSON.stringify(argument)
  // console.log(string)
  let token =  store.state.token
  let publicKey =  store.state.publicKey
  let len = string.length
  let end = 0
  let temp = ""
  let jsa = []
  let en = ""
  let encrypt = new JSEncrypt()
  encrypt.setPublicKey(publicKey)
  for(let j = 0; j < len; j++) {
    end = j + 30
    if(end > len) {
      end = len
    }
    temp = string.substring(j, end+1)
    en = encrypt.encrypt(temp)
    jsa.push(en)
    j = end
  }
  let params = {
    data: jsa,
    token: token
  }
  return params
}